<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
    </h:head>
    <h:body>

        <ui:composition template="./template/template.xhtml">

            <ui:define name="content">
                
                <!--logged-->
                <h:panelGroup rendered="#{userManager.loggedIn}" >
                    
                    
                    <h:panelGrid columns="1">

                    </h:panelGrid>
                    










                    <h:panelGrid columns="2">
                        <h:panelGroup>
                            <h2>Global Chatroom</h2><br/><br/>
                            <h:form id="Form1" >
                                <div style="height: 400px; overflow:auto; width: 500px;" id="chat" >
                                    <h:dataTable value="#{messageBean.textList}" var="current" style="vertical-align: bottom" >
                                        <h:column>
                                            <script type="javascript">
                                                var objDiv = document.getElementById("chat");
                                                objDiv.scrollTop = objDiv.scrollHeight;
                                            </script>
                                            <h:outputText value="#{current.text}"/>
                                        </h:column>
                                    </h:dataTable>
                                </div>
                                <h:inputText value="#{chatBean.message}" />
                                <h:commandButton id="buttonSave"  value="Send"
                                                 action="#{chatBean.sendMessage}"/>                                
                            </h:form>
                        </h:panelGroup>
                        <h:panelGroup>
                            <h:panelGrid columns="1"  >
                                <h:panelGroup>
                                    <div style="padding:15px;">
                                        <h2>Users Connected</h2>
                                        <div style="padding-top: 5px; height: 200px; overflow:auto; width: 200px; vertical-align: top" id="users" >
                                            <h:dataTable value="#{chatUserBean.userList}" var="currentu" style="" >
                                                <h:column>
                                                    <h:outputText value="#{currentu}"/>
                                                </h:column>
                                            </h:dataTable>
                                        </div>
                                    </div>
                                </h:panelGroup >
                                <h:panelGroup >
                                    <div style="padding:15px;">
                                        <h3>Started Games</h3>
                                        <div style="height: 200px; overflow:auto; width: 200px;" id="games" >

                                            LOLZ
                                        </div>
                                    </div>
                                </h:panelGroup>
                                <h:panelGroup >
                                    <div style="padding:15px;">
                                        <h:commandLink value="Start a new Game" action="#{}" />
                                    </div>
                                </h:panelGroup>
                            </h:panelGrid>

                        </h:panelGroup>
                    </h:panelGrid>
                    </h:panelGroup>

                    <!--not logged-->
                    <h:form id="log">
                    <h:panelGroup rendered="#{!userManager.loggedIn}">
                        <center>You are not Logged in. Please login. <br/>
                            <h:commandLink value="Login" action="login" /></center>
                    </h:panelGroup>
                    </h:form>

                
            </ui:define>

        </ui:composition>

    </h:body>
</html>

